/**
 * Created by yihua on 2017/2/26.
 */
$(document).ready(function () {
    $(".delbrand").each(function () {
        var id = $(this).parent().find("td").eq(0).text()
        $(this).click(function () {
            $("#deleteModal").modal("show");
            $("#delete_confirm").unbind('click').click(function () {
                $.ajax({
                    url: '/home/shop/delbrand',
                    timeout: 100000,
                    type: 'post',
                    dataType: 'json',
                    data: {
                        'brand_id': id
                    },
                    success: function (rs) {
                        if (rs.errno != 0) {
                            toastr.error(rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                        } else {
                            toastr.success(rs.errmsg);
                            window.location.reload();
                        }
                    },
                    error: function () {
                        toastr.error('系统错误', '', {positionClass: 'toast-bottom-center'});
                    }
                });
            });
        });
    });
});